<template>
  <div class="top" style="padding-top: -20px">
    <span style="position: absolute;padding-top:0px;right: 43%;font-size: 20px;font-weight: bold">悠哉茶桌 - 帖子管理</span>
    <span style="float:right"> <el-button type="primary" plain @click="jump">返回</el-button></span>
  </div>

  <el-card class="box-card" style="margin:auto; width: 800px;height: auto">
    <el-table
        :data="tableData"
        style="width: 100%"
        size="default">
      <el-table-column
          label="日期"
          prop="pubTime">
      </el-table-column>
      <el-table-column
          label="标题"
          prop="title">
      </el-table-column>
      <el-table-column
          label="发布者"
          prop="persion"
          :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column
          label="操作"
          prop="desc">
        <template #default="scope">
<!--          <i class="el-icon-delete" @click="deletePost(scope.row)"></i>-->
          <el-button
              size="default"
              type="danger"
              @click="deletePost(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        :page-size="size"
        layout="total, prev, pager, next"
        :total="total"
        :current-page="currentPage"
        @current-change="handleCurrentChange">
    </el-pagination>
  </el-card>
</template>

<script>
export default {
  name: "ManagePost",
  data () {
    return {
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      total: 5,
      currentPage: 1,
      size:4,
      tableData: [
        {
          pubTime: '2023-06-12',
          title: '一',
          persion: '咕嘟咕嘟',
        },{
          pubTime: '2023-06-11',
          title: '二',
          persion: '傻兜',
        },{
          pubTime: '2023-06-10',
          title: '三',
          persion: '嗝嗝',
        },
        {
          pubTime: '2023-06-19',
          title: '四',
          persion: '幻仙女',
        },
        {
          pubTime: '2023-06-19',
          title: '五',
          persion: '锅盖',
        },
      ]
    }
  },
  /*mounted () {
    this.loadArticles()
  },*/
  methods: {
    jump() {
      this.$router.push('/post/InPost')
    },
    deletePost(post) {
      this.rq.post("/post/delete", post).then(res=>{
        if (res.code === '200') {
          this.$message.success("删除成功")
          this.load()
        } else {
          this.$message.error(res.msg)
        }
      }).catch((err) => {
        this.$message.error("未知错误")
      })
    },
  }
}
</script>

<style scoped>

</style>
